package com.xxgc.qiuqiu.controller;

import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;

/**
 * 用于接收和广播游戏的数据
 */
@Controller
public class WebSocketController {

    /**
     * 接收以  /qiuqiu/position
     * 注意 发送的注解/qiuqiu可以省略，但接收的不能省略
     */
    @MessageMapping("/position")
    @SendTo("/game/position")
    public String position(String msg){
        System.out.println("msg = " + msg);
        return msg;
    }

    @MessageMapping("/skill")
    @SendTo("/game/skill")
    public String skill(String msg){
        System.out.println("msg = " + msg);
        return msg;
    }
}
